<%@ page language="java" import="java.util.*, com.rmt.www.vo.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'detail.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script src="js/jquery-1.7.1.js"></script>
		<script src="js/jquery-ui-1.8.18.custom.min.js"></script>
		<link href="css/jquery-ui-1.8.18.custom.css" rel="stylesheet"
			type="text/css" />
			<link href="css/Site.css" rel="stylesheet" type="text/css" />
		<script>
			$(function() {
				
				
				
				$('#tabs').tabs({
			  		select: function(event, ui) {
				  	 	$('input:checked').each(function(){
				  	 		$(this).attr('checked',false);
				  	 	});
			  	 	}
			  	 });
				//$('')
				$('#addDesForm').hide();
				$('#updateDesDiv').hide();
				$('#addImpForm').hide();
				$('#updateImpDiv').hide();
				$('input[class="addDes"]').click(function(){
				 	$('#updateDesDiv').hide();
				 	$('#addDesForm').show();
				});
				
				$('input[class="addImp"]').click(function(){
				 	$('#updateImpDiv').hide();
				 	$('#addImpForm').show();
				});
			
				$('input[class="deleteDes"]').click(function(){
					$('#addDesForm').hide();
					$('#updateDesDiv').hide();
					var i=$('input:checked').length;
				 	var url='deleteDesign?';
					//var pid=new Array();
					if(i<1){
						alert('please choose at least one project!');
					}else{
					
						$('input:checked').each(function(){
						 	url=url+'aid='+$(this).attr('value')+'&';
						});
						url=url.slice(0,-1);
						//将删除请求插入到request表中
						$.ajax({
						  url: url,
						  cache:false,
						  success: function(returnData, textStatus) {
						  	  $('input:checked').each(function(){
						 			//$(this).parent().parent().hide();
						 			$(this).attr('checked',false);
						 			//$(this).hide();
								});
								alert('submit this request successfully!');
							},
						    error: function(xhr, textStatus, errorThrown) {
						      	alert('fail');
						    }
						});
					}
					
				});
				
				$('input[class="deleteImp"]').click(function(){
					$('#addImpForm').hide();
					$('#updateImpDiv').hide();
					var i=$('input:checked').length;
				 	var url='deleteImplementation?';
					//var pid=new Array();
					if(i<1){
						alert('please choose at least one project!');
					}else{
					
						$('input:checked').each(function(){
						 	url=url+'aid='+$(this).attr('value')+'&';
						});
						url=url.slice(0,-1);
						//将删除请求插入到request表中
						$.ajax({
						  url: url,
						  cache:false,
						  success: function(returnData, textStatus) {
						  	  $('input:checked').each(function(){
						 			//$(this).parent().parent().hide();
						 			$(this).attr('checked',false);
						 			//$(this).hide();
								});
								alert('submit this request successfully!');
							},
						    error: function(xhr, textStatus, errorThrown) {
						      	alert('fail');
						    }
						});
					}
					
				});
			
				$('input[class="updateDes"]').click(function(){
				 	$('#addDesForm').hide();
				 	
				 	var i=$('input:checked').length;
					if(i!=1){
						alert('please choose exactly one artifact!');
					}else{
						$('#updateDesDiv').show();
						var aid;
						var url='updateDesign?aid=';
						$('input:checked').each(function(){
							aid=$(this).attr('value');
							url+=aid;
						});
						$.ajax({
						  url:url ,
						  cache: false
						}).done(function(html){
							$('#updateDesDiv').html(html);
							/*
							priority=<s:property value='artifact.priority'/>;
							$('option[class=priority]').select();
							*/
							
						});
					 }
				});
				
				$('input[class="updateImp"]').click(function(){
				 	$('#addImpForm').hide();
				 	
				 	var i=$('input:checked').length;
					if(i!=1){
						alert('please choose exactly one artifact!');
					}else{
						$('#updateImpDiv').show();
						var aid;
						var url='updateImplementation?aid=';
						$('input:checked').each(function(){
							aid=$(this).attr('value');
							url+=aid;
						});
						$.ajax({
						  url:url ,
						  cache: false
						}).done(function(html){
							$('#updateImpDiv').html(html);
							/*
							priority=<s:property value='artifact.priority'/>;
							$('option[class=priority]').select();
							*/
							
						});
					 }
				});
				
				$('input[value="detailInfo"]').click(function(){
							$('#addDesForm').hide();
							$('#updateDesDiv').hide();
							$('#addImpForm').hide();
							$('#updateImpDiv').hide();
							var i=$('input:checked').length;
							if(i!=1){
								alert('please choose exactly one artifact!');
							}else{
								var aid;
								var url='detailInfo?aid=';
								$('input:checked').each(function(){
									aid=$(this).attr('value');
									url+=aid;
								});
								var td = $("input:checked").parent();
				    			var artifacttype = td.children().eq(1).attr('value');
				    			url=url+'&artifacttype='+artifacttype;
								$.ajax({
								  url:url ,
								  cache: false
								}).done(function(html){
									$('#detailInfo').html(html);
								});
							}
				});
			});
		</script>

	</head>
	
	<body>
		<div class='page'  id='wrap'>
    <div id="header" style='background-color: #5c87b2'>
            <div id="title" >
                <h1>&nbsp;&nbsp;RMT Service for Developer</h1>
            </div>
              
            
                <div id="logindisplay">
                welcome <%=((User)session.getAttribute("currentUser")).getName()%>, <a href='../RMT'>logout</a>
             
            </div>
            <br />
            <br />
             <div id="menucontainer">
            
                <ul id="menu">              
                    <li><a href='getProjectsForOthers'>projects</a></li>
                </ul>
            	
            </div>
            </div>
             
 	
		<div id="tabs">
			<ul>
				<li>
					<a href="#feature"><span>feature</span> </a>
				</li>
				<li>
					<a href="#requirement"><span>requirement</span> </a>
				</li>
				<li>
					<a href="#design"><span>design</span> </a>
				</li>
				<li>
					<a href="#implementation"><span>implementation</span> </a>
				</li>
				<li>
					<a href="#testCase"><span>test case</span> </a>
				</li>
			</ul>

			<div id='feature'>
				<table border="1">
					<tr>
						<th>
							choose
						</th>
						<th>
							title
						</th>
						<th>
							author
						</th>
						<th>
							status
						</th>
						<th>
							version
						</th>
						<th>
							priority
						</th>
					</tr>
					<s:iterator value="featureList" id="list" status="st">
						<tr>
							<td>
								<input type="checkbox" value='<s:property value="#list.id" />' />
								<input type="hidden" value='<s:property value="#list.artifacttype" />' />
							</td>
							<td>
								<s:property value="#list.title" />
							</td>
							<td>
								<s:property value="#list._authorname" />
							</td>
							<td>
								<s:property value="#list.status" />
							</td>
							<td>
								<s:property value="#list.version" />
							</td>
							<td>
								<s:property value="#list.priority" />
							</td>
						</tr>
					</s:iterator>
				</table>
				<input type="button" value='detailInfo' />
			</div>
			<div id='requirement'>
				<table border="1">
					<tr>
						<th>
							choose
						</th>
						<th>
							title
						</th>
						<th>
							author
						</th>
						<th>
							status
						</th>
						<th>
							version
						</th>
						<th>
							priority
						</th>
					</tr>
					<s:iterator value="requirementList" id="list" status="st">
						<tr>
							<td>
								<input type="checkbox" value='<s:property value="#list.id" />' />
								<input type="hidden" value='<s:property value="#list.artifacttype" />' />
							</td>
							<td>
								<s:property value="#list.title" />
							</td>
							<td>
								<s:property value="#list._authorname" />
							</td>
							<td>
								<s:property value="#list.status" />
							</td>
							<td>
								<s:property value="#list.version" />
							</td>
							<td>
								<s:property value="#list.priority" />
							</td>
						</tr>
					</s:iterator>
				</table>
				<input type="button" value='detailInfo' />
			</div>
			<div id='design'>
				<table border="1">
					<tr>
						<th>
							choose
						</th>
						<th>
							title
						</th>
						<th>
							author
						</th>
						<th>
							status
						</th>
						<th>
							function
						</th>
						<th>
							version
						</th>
						<th>
							priority
						</th>
					</tr>
					<s:iterator value="designList" id="list" status="st">
						<tr>
							<td>
								<input type="checkbox" value='<s:property value="#list.id" />' />
								<input type="hidden" value='<s:property value="#list.artifacttype" />' />
							</td>
							<td>
								<s:property value="#list.title" />
							</td>
							<td>
								<s:property value="#list._authorname" />
							</td>
							<td>
								<s:property value="#list.status" />
							</td>
							<td>
								<s:property value="#list.function" />
							</td>
							<td>
								<s:property value="#list.version" />
							</td>
							<td>
								<s:property value="#list.priority" />
							</td>
						</tr>
					</s:iterator>
				</table>
				<input type="button" value='add' class='addDes' />
				<input type="button" value='delete' class='deleteDes' />
				<input type="button" value='detailInfo' />
				<input type="button" value='update' class='updateDes' />
				<form id='addDesForm' action='addDesign' method='post'>
					<table>
						<tr>
							<td>
								title
							</td>
							<td>
								<input type='text' name='title' />
							</td>
						</tr>
						<tr>
							<td>
								version
							</td>
							<td>
								<input type='text' name='version' />
							</td>
						</tr>
						<tr>
							<td>
								priority
							</td>
							<td>
								<select name='priority'>
									<option selected="selected">high</option>
									<option>medium</option>
									<option>low</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								status
							</td>
							<td>
								<select name='status'>
									<option selected="selected">proposed</option>
									<option>approved</option>
									<option>implemented</option>
									<option>verified</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								architect
							</td>
							<td>
								<input type='text' name='architect' />
							</td>
						</tr>
						<tr>
							<td>
								consideration
							</td>
							<td>
								<input type='text' name='consideration' />
							</td>
						</tr>
						<tr>
							<td>
								input
							</td>
							<td>
								<input type='text' name='input' />
							</td>
						</tr>
						<tr>
							<td>
								function
							</td>
							<td>
								<input type='text' name='function' />
							</td>
						</tr>
						<tr>
							<td>
								output
							</td>
							<td>
								<input type='text' name='output' />
							</td>
						</tr>
						<tr>
							<td>
								performance request
							</td>
							<td>
								<input type='text' name='perfrequest' />
							</td>
						</tr>
						<tr>
							<td>
								security request
							</td>
							<td>
								<input type='text' name='securityrequest' />
							</td>
						</tr>
						<tr>
							<td>
								storage request
							</td>
							<td>
								<input type='text' name='storagerequest' />
							</td>
						</tr>
						<tr>
							<td>
								inner interface
							</td>
							<td>
								<input type='text' name='innerinterface' />
							</td>
						</tr>
						<tr>
							<td>
								outer interface
							</td>
							<td>
								<input type='text' name='outerinterface' />
							</td>
						</tr>
						<tr>
							<td>
								comment
							</td>
							<td>
								<textarea rows="10" cols="100" name='comment'></textarea>
							</td>
						</tr>
						<tr>
							<td>
								cost
							</td>
							<td>
								<input type='text' name='cost' />
							</td>
						</tr>
						<tr>
							<td>
								effort
							</td>
							<td>
								<input type='text' name='effort' />
							</td>
						</tr>
						<tr>
							<td>
								risk
							</td>
							<td>
								<input type='text' name='risk' />
							</td>
						</tr>
						<tr>
							<td>
								<input type="text" name='pid' value='<s:property value="pid" />' style='display: none'/>
							</td>
							<td>
								<input type='submit' value='submit' />
							</td>
						</tr>
					</table>
				</form>
				<div id=updateDesDiv></div>
			</div>
			<div id='implementation'>
				<table border="1">
					<tr>
						<th>
							choose
						</th>
						<th>
							title
						</th>
						<th>
							author
						</th>
						<th>
							status
						</th>
						<th>
							function
						</th>
						<th>
							language
						</th>
						<th>
							version
						</th>
						<th>
							priority
						</th>
					</tr>
					<s:iterator value="implementationList" id="list" status="st">
						<tr>
							<td>
								<input type="checkbox" value='<s:property value="#list.id" />' />
								<input type="hidden" value='<s:property value="#list.artifacttype" />' />
							</td>
							<td>
								<s:property value="#list.title" />
							</td>
							<td>
								<s:property value="#list._authorname" />
							</td>
							<td>
								<s:property value="#list.status" />
							</td>
							<td>
								<s:property value="#list.function" />
							</td>
							<td>
								<s:property value="#list.language" />
							</td>
							<td>
								<s:property value="#list.version" />
							</td>
							<td>
								<s:property value="#list.priority" />
							</td>
						</tr>
					</s:iterator>
				</table>
				<input type="button" value='add' class='addImp'/>
				<input type="button" value='delete' class='deleteImp'/>
				<input type="button" value='detailInfo' />
				<input type="button" value='update' class='updateImp' />
				<form id='addImpForm' action='addImplementation' method='post'>
					<table>
						<tr>
							<td>
								title
							</td>
							<td>
								<input type='text' name='title' />
							</td>
						</tr>
						<tr>
							<td>
								version
							</td>
							<td>
								<input type='text' name='version' />
							</td>
						</tr>
						<tr>
							<td>
								priority
							</td>
							<td>
								<select name='priority'>
									<option selected="selected">high</option>
									<option>medium</option>
									<option>low</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								status
							</td>
							<td>
								<select name='status'>
									<option selected="selected">proposed</option>
									<option>approved</option>
									<option>implemented</option>
									<option>verified</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								function
							</td>
							<td>
								<input type='text' name='function' />
							</td>
						</tr>
						<tr>
							<td>
								input
							</td>
							<td>
								<input type='text' name='input' />
							</td>
						</tr>
						<tr>
							<td>
								output
							</td>
							<td>
								<input type='text' name='output' />
							</td>
						</tr>
						<tr>
							<td>
								processing steps
							</td>
							<td>
								<input type='text' name='processingsteps' />
							</td>
						</tr>
						<tr>
							<td>
								algorithm
							</td>
							<td>
								<input type='text' name='algorithm' />
							</td>
						</tr>
						<tr>
							<td>
								errorhandling
							</td>
							<td>
								<input type='text' name='errorhandling' />
							</td>
						</tr>
						<tr>
							<td>
								language
							</td>
							<td>
								<input type='text' name='language' />
							</td>
						</tr>
						<tr>
							<td>
								code
							</td>
							<td>
								<textarea rows="10" cols="100" name='code'></textarea>
							</td>
						</tr>
						<tr>
							<td>
								comment
							</td>
							<td>
								<textarea rows="10" cols="100" name='comment'></textarea>
							</td>
						</tr>
						<tr>
							<td>
								cost
							</td>
							<td>
								<input type='text' name='cost' />
							</td>
						</tr>
						<tr>
							<td>
								effort
							</td>
							<td>
								<input type='text' name='effort' />
							</td>
						</tr>
						<tr>
							<td>
								risk
							</td>
							<td>
								<input type='text' name='risk' />
							</td>
						</tr>
						<tr>
							<td>
								<input type="text" name='pid' value='<s:property value="pid" />' style='display: none'/>
							</td>
							<td>
								<input type='submit' value='submit' />
							</td>
						</tr>
					</table>
				</form>
				<div id=updateImpDiv></div>
			</div>
			<div id='testCase'>
				<table border="1">
					<tr>
						<th>
							choose
						</th>
						<th>
							title
						</th>
						<th>
							author
						</th>
						<th>
							status
						</th>
						<th>
							version
						</th>
						<th>
							priority
						</th>
					</tr>
					<s:iterator value="testcaseList" id="list" status="st">
						<tr>
							<td>
								<input type="checkbox" value='<s:property value="#list.id" />' />
								<input type="hidden" value='<s:property value="#list.artifacttype" />' />
							</td>
							<td>
								<s:property value="#list.title" />
							</td>
							<td>
								<s:property value="#list._authorname" />
							</td>
							<td>
								<s:property value="#list.status" />
							</td>
							<td>
								<s:property value="#list.version" />
							</td>
							<td>
								<s:property value="#list.priority" />
							</td>
						</tr>
					</s:iterator>
				</table>
				<input type="button" value='detailInfo' />
			</div>
		</div>

	<div id='detailInfo'>
	</div>
	
	   <div class="push"></div>
  	<div id="footer" style="background-color:#5c87b2;">
  	  <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:hidden;background-color:#5c87b2;">							
		<tbody style="border:hidden">
			<tr style="border: hidden">	
				<td width="160" style="border: hidden">&nbsp;</td>											   		<td>									
				<table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:hidden;">	
					<tbody style="border: hidden">
						<tr style="border: hidden">
							<td height="20px"><font color='#ffffff'>©2012 Copyright NJU SEI RMT team</font></td>										
						</tr>										
						<tr style="border: hidden">											
							<td height="20px"><font color='#ffffff'>2012 graduation project: requirement management tool</font></td>	
						</tr>										
						<tr style="border: hidden">					
							<td height="20px"><font color='#ffffff'>project homepage：http://code.google.com/p/rmt-ss/</font></td>		
						</tr>									
					</tbody>
				</table>								
				</td>							
			</tr>						
		</tbody>
	</table>	
  	</div>
  	</div>
	</body>
</html>
